package com.ruoyi.web.controller.mini;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.security.context.UserContextHolder;
import com.ruoyi.system.domain.MyForum;
import com.ruoyi.system.domain.dto.ForumDTO;
import com.ruoyi.system.service.IMyForumService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/mini/forum")
@Api(tags = "论坛相关接口")
public class ForumController extends BaseController {

    @Autowired
    private IMyForumService myForumService;

    /**
     * 查询论坛列表
     */
    @GetMapping("/list")
    public AjaxResult list(MyForum myForum) {
        return success(myForumService.selectMyForumList(myForum));
    }

    /**
     * 删除论坛
     */
    @GetMapping("/del")
    public AjaxResult del(Long fid) {
        return success(myForumService.deleteMyForumById(fid));
    }

    /**
     * 发布论坛
     */
    @PostMapping("/issue")
    public AjaxResult issue(@RequestBody ForumDTO forumDTO) {
        Long id = UserContextHolder.getCurrentUser().getId();
        forumDTO.setUid(id);
        return success(myForumService.issueForum(forumDTO));
    }

}
